package com.example.broadcast.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import android.widget.Toast

class SecondOrderReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context?, intent: Intent?) {
        context?.let {


            var msg = intent?.getStringExtra("msg") ?: ""

            Log.d("SecondOrderReceiver", "收到广播  $msg")

            val processOnlyOnce = intent?.getStringExtra("processOnlyOnce")
            if( processOnlyOnce!= null){
                msg += processOnlyOnce + "中断广播"
                abortBroadcast()
            }

            Toast.makeText(it, "SecondOrderReceiver 收到 $msg", Toast.LENGTH_SHORT).show()


        }
    }
}